package cn.yu.od;

import java.util.*;
import java.util.stream.Collectors;

/**
 * https://blog.csdn.net/banxia_frontend/article/details/124484923
 *
 * test case1
 * 10 5 6
 * 1 2 3 4 5 6 7 8 9 10
 * 4 5 6 7 8
 *
 * test case2
 * 10 4 6
 * 10 9 8 7 6 5 4 3 2 1
 * 4 5 6 7
 *
 *
 *
 * @Author : Ning Yu
 * @create 2023/3/24 17:08
 */
public class YuDIngJiuDian {

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        String input = scanner.nextLine();
        String[] ss = input.split(" ");
        int n = Integer.parseInt(ss[0]);
        int k = Integer.parseInt(ss[1]);
        int x = Integer.parseInt(ss[2]);
        String arr = scanner.nextLine();
        String[] arrs = arr.split(" ");
        int[][] diffs = new int[n][2];
        for (int i = 0; i < n; i++) {
            int val = Integer.parseInt(arrs[i]);
            diffs[i][0] = val;
            diffs[i][1] = Math.abs(val - x);
        }
        List<int[]> collect = Arrays.stream(diffs)
                .sorted(Comparator.comparingInt(node -> node[0]))
                .sorted(Comparator.comparingInt(node -> node[1]))
                .collect(Collectors.toList());

        ArrayList<Integer> integers = new ArrayList<>(n);
        for (int i = 0; i < k; i++) {
            integers.add(collect.get(i)[0]);
        }
        integers.sort(Integer::compareTo);

        String str = integers.stream().map(String::valueOf).collect(Collectors.joining(" "));
        System.out.println(str);

    }
}
